package com.manolo.framework.listener.dispatcher;

import java.util.ArrayList;
import java.util.List;

import com.manolo.framework.listener.DateListener;
import com.manolo.framework.listener.event.DateEvent;

public class DateDispatcher {
	private static DateDispatcher instance;
	private List<DateListener> listeners;

	private DateDispatcher() {
		this.listeners = new ArrayList<DateListener>();
	}

	public synchronized static DateDispatcher getInstance() {
		if(DateDispatcher.instance == null) {
			DateDispatcher.instance = new DateDispatcher();
		}

		return DateDispatcher.instance;
	}

	public void addDateListener(DateListener listener) {
		this.listeners.add(listener);
	}

	public void removeDateListener(DateListener listener) {
		this.listeners.remove(listener);
	}

	public void dispatchDateEvent(DateEvent event) {
		for (DateListener listener : this.listeners) {
			listener.moveAction(event);
		}
	}
}
